/**
 * List of Role Events.
 * 
 * @author MECOM
 * @version 1.0
 * @since 2012-05-24
 */

package br.ufrgs.meetapp.enums;

public enum Role {
	
	ADMIN(2, "Admin"),
	FREEMIUM(19, "Freemium"),
	REPORTS_READ(101, "Reports_Read"),
	MESSAGES_READ(102, "Messages_Read"),
	GEOFENCE_READ(103, "Geofence_Read"),
	POI_READ(104, "POI_Read"),
	RULES_READ(105, "Rules_Read"),	
	WORKORDER_READ(116, "WorkOrder_Read"),	
	TRACK_READ(117, "Track_Read"),
	REPORTS_WRITE(201, "Reports_Write"),
	MESSAGES_WRITE(202, "Messages_Write"),
	GEOFENCE_WRITE(203, "Geofence_Write"),	
	POI_WRITE(204, "POI_Write"),
	RULES_WRITE(205, "Rules_Write"),
	WORKORDER_WRITE(216, "WorkOrder_Write"),	
	TRACK_WRITE(217, "Track_Write");
	
	private String roleTextCode;
	private int roleCode;
	
	private Role(int _roleCode, String _roleTextCode)
	{
		roleCode = _roleCode;
		roleTextCode = _roleTextCode;
	}
	
	public String getText()
	{
		return roleTextCode;
	}
	
	public int getCode() {
		return roleCode;
	}
	
	/***
	 * Returns the ResultType enum by ID
	 * @param _result_id 
	 * @return
	 */
	public static Role getRole(int _roleCode) {
		
		switch (_roleCode) {
			case 2: return Role.ADMIN;
			case 19: return Role.FREEMIUM;
			case 101: return Role.REPORTS_READ;
			case 102: return Role.MESSAGES_READ;
			case 103: return Role.GEOFENCE_READ;
			case 104: return Role.POI_READ;
			case 105: return Role.RULES_READ;
			case 116: return Role.WORKORDER_READ;
			case 117: return Role.TRACK_READ;
			case 201: return Role.REPORTS_WRITE;
			case 202: return Role.MESSAGES_WRITE;
			case 203: return Role.GEOFENCE_WRITE;
			case 204: return Role.POI_WRITE;
			case 205: return Role.RULES_WRITE;
			case 216: return Role.WORKORDER_WRITE;
			case 217: return Role.TRACK_WRITE;
			default: return null;
		}
	}
		
}
